package com.chao.auth.service;

import org.springframework.security.oauth2.common.util.RandomValueStringGenerator;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.security.oauth2.provider.code.InMemoryAuthorizationCodeServices;

/**
 * @author : Rookie
 * @description :
 * @date : 2022/4/30
 */
public class CustomAuthorizationCodeServices extends InMemoryAuthorizationCodeServices {

    private RandomValueStringGenerator generator = new RandomValueStringGenerator(16);

    @Override
    public String createAuthorizationCode(OAuth2Authentication authentication) {
        String code = generator.generate().toUpperCase();
        store(code,authentication);
        return code;
    }
}
